<?php

namespace App\Http\Requests\Backend\Bank;

use App\Http\Requests\Backend\BaseRequest;
use Illuminate\Foundation\Http\FormRequest;

class BankRequest extends BaseRequest
{
    public $routeName;

    public function __construct(){
        $this->routeName = \Route::currentRouteName();
        parent::__construct();
    }
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->routeName){
            case 'bank.store':
                return $this->storeRules();
                break;
            case 'bank.update':
                return $this->storeRules();
                break;
            default:
                return [];
        }
    }

    public function storeRules(){
        return [
            'bank_name' => 'required',
            'path' => 'required',
            'bin_num' => 'required',
//            'single_limit' => 'required',
//            'day_limit' => 'required',
        ];
    }

    public function messages(){
        switch ($this->routeName){
            case 'bank.store':
                return $this->storeMessages();
                break;
            case 'bank.update':
                return $this->storeMessages();
                break;
            default:
                return [];
        }
    }

    public function storeMessages(){
        return [
            'bank_name.required' => '银行名称不能为空',
            'path.required' => '银行icon的url路径不能为空',
            'bin_num.required' => '银行卡号前6位数字不能为空',
//            'single_limit.required' => '单笔限额不能为空',
//            'day_limit.required' => '单日限额不能为空',
        ];
    }
}
